/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.openbrew.openbrewrf.views;

import com.openbrew.openbrewrf.AdditiveNotes;
import com.openbrew.openbrewrf.CommonBrewSupplies;
import com.openbrew.openbrewrf.InventoryUsage;
import com.openbrew.openbrewrf.POSGlassWare;
import com.openbrew.openbrewrf.POSLineItems;
import com.openbrew.openbrewrf.RecipeAdditives;
import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Version;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author chapmand
 */
@Entity
@Table(name = "Supplies")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "POSSupplyView.findResaleableItems", query = "SELECT p FROM POSSupplyView p WHERE p.supResalable = 'true' ORDER BY p.supName ASC"),
    @NamedQuery(name = "POSSupplyView.findAll", query = "SELECT s FROM POSSupplyView s ORDER BY s.supName ASC"),
    @NamedQuery(name = "POSSupplyView.findAllSAF", query = "SELECT s FROM POSSupplyView s WHERE s.supWH = '130' ORDER BY s.supName ASC")})
public class POSSupplyView implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "SupID")
    private Integer supID;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 100)
    @Column(name = "SupName")
    private String supName;
    @Basic(optional = false)
    @NotNull
    @Column(name = "SupWH")
    private int supWH;
    @Basic(optional = false)
    @NotNull
    @Column(name = "Resaleable")
    private boolean supResalable;
    @Column(name = "ReSalePrice")
    private float supReSalePrice;
    @Basic(optional = false)
    @NotNull
    @Column(name = "taxExempt")
    private boolean taxExempt;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 50)
    @Column(name = "SupUnits")
    private String supUnits;
    @Basic(optional = false)
    @NotNull
    @Column(name = "SupPrice")
    private float supPrice;
    @Basic(optional = false)
    @NotNull
    @Column(name = "version")
    @Version
    private int version;
    @OneToMany(mappedBy = "supply")
    private Collection<POSLineItems> lineItemCollection;
    @OneToMany(mappedBy = "glassWareSupply")
    private Collection<POSGlassWare> glassWareCollection;
    @OneToMany(mappedBy = "supply")
    private Collection<RecipeAdditives> recipeAdditiveCollection;
    @OneToMany(mappedBy = "supply")
    private Collection<AdditiveNotes> additiveNoteCollection;
    @OneToMany(mappedBy = "supplyID")
    private Collection<CommonBrewSupplies> cbsCollection;
    @OneToMany(mappedBy = "supplyID")
    private Collection<InventoryUsage> invUsageCollection;

    public POSSupplyView() {
    }

    public POSSupplyView(Integer supID) {
        this.supID = supID;
    }

    public POSSupplyView(Integer supID, String supName, int supWH, boolean supResalable, float supReSalePrice, String supUnits, boolean taxExempt, float supPrice) {
        this.supID = supID;
        this.supName = supName;
        this.supWH = supWH;
        this.supResalable = supResalable;
        this.supReSalePrice = supReSalePrice;
        this.supUnits = supUnits;
        this.taxExempt = taxExempt;
        this.supPrice = supPrice;
    }

    public Integer getSupID() {
        return supID;
    }

    public void setSupID(Integer supID) {
        this.supID = supID;
    }

    public String getSupName() {
        return supName;
    }

    public void setSupName(String supName) {
        this.supName = supName;
    }

    public int getSupWH() {
        return supWH;
    }

    public void setSupWH(int supWH) {
        this.supWH = supWH;
    }

    public boolean isSupResalable() {
        return supResalable;
    }

    public void setSupResalable(boolean supResalable) {
        this.supResalable = supResalable;
    }

    public float getSupReSalePrice() {
        return supReSalePrice;
    }

    public void setSupReSalePrice(float supReSalePrice) {
        this.supReSalePrice = supReSalePrice;
    }

    public String getSupUnits() {
        return supUnits;
    }

    public void setSupUnits(String supUnits) {
        this.supUnits = supUnits;
    }

    public boolean isTaxExempt() {
        return taxExempt;
    }

    public void setTaxExempt(boolean taxExempt) {
        this.taxExempt = taxExempt;
    }

    public float getSupPrice() {
        return supPrice;
    }

    public void setSupPrice(float supPrice) {
        this.supPrice = supPrice;
    }

    public int getVersion() {
        return version;
    }

    public void setVersion(int version) {
        this.version = version;
    }

    @XmlTransient
    public Collection<POSLineItems> getLineItemCollection() {
        return lineItemCollection;
    }

    public void setLineItemCollection(Collection<POSLineItems> lineItemCollection) {
        this.lineItemCollection = lineItemCollection;
    }

    @XmlTransient
    public Collection<POSGlassWare> getGlassWareCollection() {
        return glassWareCollection;
    }

    public void setGlassWareCollection(Collection<POSGlassWare> glassWareCollection) {
        this.glassWareCollection = glassWareCollection;
    }

    @XmlTransient
    public Collection<RecipeAdditives> getRecipeAdditiveCollection() {
        return recipeAdditiveCollection;
    }

    public void setRecipeAdditiveCollection(Collection<RecipeAdditives> recipeAdditiveCollection) {
        this.recipeAdditiveCollection = recipeAdditiveCollection;
    }

    @XmlTransient
    public Collection<AdditiveNotes> getAdditiveNoteCollection() {
        return additiveNoteCollection;
    }

    public void setAdditiveNoteCollection(Collection<AdditiveNotes> additiveNoteCollection) {
        this.additiveNoteCollection = additiveNoteCollection;
    }

    @XmlTransient
    public Collection<CommonBrewSupplies> getCbsCollection() {
        return cbsCollection;
    }

    public void setCbsCollection(Collection<CommonBrewSupplies> cbsCollection) {
        this.cbsCollection = cbsCollection;
    }

    @XmlTransient
    public Collection<InventoryUsage> getInvUsageCollection() {
        return invUsageCollection;
    }

    public void setInvUsageCollection(Collection<InventoryUsage> invUsageCollection) {
        this.invUsageCollection = invUsageCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (supID != null ? supID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof POSSupplyView)) {
            return false;
        }
        POSSupplyView other = (POSSupplyView) object;
        if ((this.supID == null && other.supID != null) || (this.supID != null && !this.supID.equals(other.supID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.openbrew.openbrewrf.POSSupplyView[ supID=" + supID + " ]";
    }
    
}
